{extend name="main/index" /}
{block name="main"}
<div class="main-content">
    <div class="breadcrumbs" id="breadcrumbs">
        <script type="text/javascript">
            try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
        </script>

        <ul class="breadcrumb">
            <li>
                <i class="icon-home home-icon"></i>
                <a href="#">Home</a>
            </li>

            <li>
                <a href="#">Tables</a>
            </li>
            <li class="active">角色列表</li>
        </ul><!-- .breadcrumb -->

        <div class="nav-search" id="nav-search">
            <form class="form-search">
                <span class="input-icon">
                    <input type="text" placeholder="Search ..." class="nav-search-input" id="nav-search-input" autocomplete="off" />
                    <i class="icon-search nav-search-icon"></i>
                </span>
            </form>
        </div><!-- #nav-search -->
    </div>

    <div class="page-content">
        <div class="row">
            <div class="col-xs-12">
                <div class="row">
                    <div class="col-xs-12">
                        <div class="table-responsive">
                            <table id="sample-table-2" class="table table-striped table-bordered table-hover">
                                <thead>
                                    <tr>
                                        <!-- <th class="center">
                                            <label>
                                                <input type="checkbox" class="ace" />
                                                <span class="lbl"></span>
                                            </label>
                                        </th> -->
                                        <th>ID</th>
                                        <th>角色名</th>
                                        <th class="hidden-480">角色功能</th>

                                        <th>
                                            <i class="icon-time bigger-110 hidden-480"></i>
                                            角色权限
                                        </th>
                                        <!-- <th>状态</th> -->
                                        <th class="hidden-480">操作</th>

                                    </tr>
                                </thead>
                                <tbody>
                                {volist name="list" id="v"}
                                    <tr>
                                        <td>{$v['id']}</td>
                                        <td>{$v['name']}</td>
                                        <td>{$v['remark']}</td>
                                        <td>
                                            {volist name="v['node']" id = "x"}
                                                <span style="color:#999">
                                                    {$x[0]}
                                                </span>
                                            {/volist}
                                            <!-- <?php //var_dump($v['node']); exit; ?> -->
                                            <!-- <button data-id="{$v['id']}" class="btn btn-xs btn-primary show-btn" data-toggle="modal" data-target="#myModal" >查看更多</button> -->
                                        </td>
                                        <!-- <td>
                                            <?php if ($v['status'] == 1) : ?>
                                                启用
                                            <?php else: ?>
                                                禁用
                                            <?php endif  ?>
                                        </td> -->
                                        <td>
                                            <!-- <a href="">删除</a> -->
<<<<<<< HEAD
                                            <a href="{:url('admin/role/edit', ['id' => $v['id']])}">修改</a> | 
                                            <a href="{:url('admin/role/shownode', ['id' => $v['id']])}">分配节点</a> | 
                                            <button data-id="{$v['id']}" class="btn btn-xs btn-primary edit-btn" data-toggle="modal" data-target=".bs-example-modal-sm">查看</button> |
=======
<<<<<<< HEAD:tp5/application/admin/view/role/index.html
                                            <a href="{:url('admin/role/edit', ['id' => $v['id']])}">修改</a> | 
                                            <a href="{:url('admin/role/shownode', ['id' => $v['id']])}">分配节点</a> | 
                                            <button data-id="{$v['id']}" class="btn btn-xs btn-primary edit-btn" data-toggle="modal" data-target=".bs-example-modal-sm">编辑</button> |
=======
                                            <a href="{:url('admin/role/edit', ['id' => $v['id']])}">修改</a>
                                            <a href="{:url('admin/role/shownode', ['id' => $v['id']])}">分配节点</a>
>>>>>>> 6accf0d8d13eabad30f3c6fb808de714beb2cd83:tp5/application/admin/view/role/index.html
>>>>>>> a40bd7c37eef93aca4b7ae3126fd10da65b4232b
                                            <button data-id="{$v['id']}" class="btn btn-xs btn-danger del-btn">删除</button>
                                        </td>
                                    </tr>
                                {/volist}
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div><!-- /.col -->
        </div><!-- /.row -->
    </div><!-- /.page-content -->
</div>
<<<<<<< HEAD
=======
<<<<<<< HEAD:tp5/application/admin/view/role/index.html
>>>>>>> a40bd7c37eef93aca4b7ae3126fd10da65b4232b

<!-- Modal -->
<div class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" style="margin-top: 100px">
  <div class="modal-dialog modal-sm" role="document">
    <div class="modal-content">
        <div class="row">
            <div class="col-md-12">
<<<<<<< HEAD
                <form action="{:url('admin/role/update', ['id'=>$v['id']])}" onsubmit="return saveAjax()">
                    <hr>
                    <div>
                        <input type="hidden" name="_method" value="PUT">
                        <input type="hidden" id="id" name="id" value="">
                        <div class="form-group">
                            <label for="" class="col-sm-2 control-label">角色ID：</label>
                            <div class="col-sm-4">
                                <input type="text" id="name" name="name" class="form-control" value="" style="width:350px;">
                            </div>
                        </div>
                        <br><br>
                        <div class="form-group">
                            <label for="" class="col-sm-2 control-label">角色名：</label>
                            <div class="col-sm-4">
                                <input type="text" id="name" name="name" class="form-control" value="" style="width:350px;">
                            </div>
                        </div>
                        <br><br>
                        <div class="form-group">
                            <label for="" class="col-sm-2 control-label">角色描述：</label>
                            <div class="col-sm-4">
                                <input  type="text" id="remark" name="remark" class="form-control" value="" style="width:350px;">
                            </div>
                        </div>
                        <br><br>    
                        <div class="form-group">
                            <label for="" class="col-sm-2 control-label">角色状态：</label>
                            <div class="col-sm-4">
                                <input  type="text" id="status" name="status" class="form-control" value="" style="width:350px;">
                            </div>
                        </div>
                        <br><br>
                        <hr>
                        <!-- <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-4">
                              <button type="submit" class="btn btn-default save-btn">保存</button>
                            </div>
                        </div> -->
                        <div class="modal-footer">
                            <button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
                        </div>
                    </div>
                </form>
=======
                <hr>
                <div>
                    <input type="hidden" name="_method" value="PUT">
                    <input type="hidden" id="id" name="id" value="">
                    <div class="form-group">
                        <label for="" class="col-sm-2 control-label">角色名：</label>
                        <div class="col-sm-4">
                            <input type="text" id="name" name="name" class="form-control" value="" style="width:350px;">
                        </div>
                    </div>
                    <br><br>
                    <div class="form-group">
                        <label for="" class="col-sm-2 control-label">角色描述：</label>
                        <div class="col-sm-4">
                            <input  type="text" id="remark" name="remark" class="form-control" value="" style="width:350px;">
                        </div>
                    </div>
                    <hr>
                    <div class="form-group">
                        <div class="col-sm-offset-2 col-sm-4">
                          <button type="submit" class="btn btn-default save-btn">保存</button>
                        </div>
                    </div>
                </div>
>>>>>>> a40bd7c37eef93aca4b7ae3126fd10da65b4232b
            </div>
        </div>
    </div>
  </div>
</div>
{/block}


{block name="myjs"}
{js href="/static/admin/assets/js/toastr.min.js"}
<script>
    $(function () {
        $('.del-btn').click(function () {
            var ac_id = $(this).attr('data-id');
            console.log('我要删除: ' + ac_id + '的角色');

            if (confirm('你确定要 [ 删 除 ] 吗?')) {
                var obj = $(this).parents('tr');
                // console.log(obj);
                delAjax(ac_id, obj);
            }
        });

        // 找到要编辑的数据
        $('.edit-btn').click(function(){
            var ac_id = $(this).attr('data-id');
            console.log('我要编辑:'+ac_id+'的角色');
            findAjax(ac_id);
            
        });

        // 保存数据
        $('.save-btn').click(function(){
            var ac_id = $('#id').val();
            console.log('我要保存:'+ac_id+'的角色');
            saveAjax(ac_id);

        });



        // 设置弹框参数
        toastr.options = {
            closeButton: true,// 是否显示关闭按钮
            progressBar: true,// 实现显示计时条
            timeOut: "3000",  // 自动关闭时间
            positionClass: "toast-top-right" // 提示位置
            // positionClass: "toast-top-full-width" // 提示位置
            // toast-top-full-width 顶端，宽度铺满整个屏幕
            // toast-top-right  顶端右边
        };
    });

    // 执行ajax编辑
    function findAjax(id) {
        $.ajax({
            dataType:'json',
            type: 'get',
            url: '/Role/'+ id,
            success: function (data) {
                console.log(data);
                if (data.status) {
                    var msg = data.data;
                    $('.modal-content #id').val(msg.id);
                    $('.modal-content #name').val(msg.name);
                    $('.modal-content #remark').val(msg.remark);
<<<<<<< HEAD
                    $('.modal-content #status').val(msg.status==1?'有效':'禁用');
=======
>>>>>>> a40bd7c37eef93aca4b7ae3126fd10da65b4232b
                }else{
                    toastr.error(data.info,'WARING');
                }
            },
            error: function (){
                alert('AJAX 请求出现错误!');
            }
        });
    }


    // 执行保存ajax
    function saveAjax(id){
        $.ajax({
            dataType: 'json',
            type: 'put',
            url: '/Role/'+ id,
            success: function (data) {
                if (data.status) {
                    toastr.success(data.info);
                } else {
                    toastr.error(data.info, 'FBI WARNING:');
                }
            },
            error: function () {
                alert('AJAX执行失败');
            }
        });
    }



    // 执行ajax删除
    function delAjax(id, obj) {
        $.ajax({
            type: 'delete',
            // url  : '{:url("admin/role/delete", ["id"=>'+id+'])}',
            url: '/Role/' + id,
            dataType: 'json',
            success: function (data) {
                console.log(data);
                if (data.status) {
                    toastr.success(data.info);
                    obj.remove();
                } else {
                    toastr.error(data.info, 'FBI WARNING:');
                }
            },
            error: function () {
                alert('AJAX执行失败');
            }
        });
    }
</script>
{/block}


<<<<<<< HEAD
=======
=======
{/block}
>>>>>>> 6accf0d8d13eabad30f3c6fb808de714beb2cd83:tp5/application/admin/view/role/index.html
>>>>>>> a40bd7c37eef93aca4b7ae3126fd10da65b4232b
